/*
 * vectorizednet.h
 *
 *  Created on: Nov 19, 2013
 *      Author: cinus
 */

#ifndef VECTORIZEDNET_H_
#define VECTORIZEDNET_H_

#include "net.h"
#include "matrix.h"
#include "types.h"

struct vectorizedNet;

typedef float32* (*afpv)(struct vectorizedNet*, float32*, uint32);
typedef void (*cdwv)(struct vectorizedNet* vnet);

struct vectorizedNet {
	uint32 numLayers;
	uint32* neuronsInLayer;

	matrix_tp *w; //weights without biases
	matrix_tp *dw;
	matrix_tp *b; //bias weights
	matrix_tp *db;
	matrix_tp *a;
	matrix_tp *z; //output of the "neuron"
	matrix_tp *d; //lower case delta
	matrix_tp *g; //gradient
	matrix_tp *gb; //gradient biases
	afpv *af;
	afpv *daf;
	float32 (*errorComputation)(float32 *output, float32 *target, size_t size);
	float32 error;
	float32 lastError;
	cdwv computeDeltaWeights;

	//settings
	uint32 onlineTraining;
	float32 eta;
	float32 alpha;
	uint32 maxEpochsFromMinimum;
	uint32 maxEpochs;
};

typedef struct vectorizedNet vectorizedNet_t;
typedef vectorizedNet_t* vectorizedNet_tp;

//public
vectorizedNet_tp convertNet(netdata_tp stdNet);
void printVecNet(vectorizedNet_tp vnet);
//return the number of the input for the specified layer
uint32 neuronsInLayer(vectorizedNet_tp net, uint32 layerId);

void reserveNetSpaceV(vectorizedNet_tp srcVNet, vectorizedNet_tp dstVNetPtr);
void copyNetV(vectorizedNet_tp srcVNet, vectorizedNet_tp dstVNet);

void destroyNetworkV(vectorizedNet_tp vnet);
//private

#endif /* VECTORIZEDNET_H_ */
